package com.hymjweb.demo.framework.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;

public class StringUtil {

	/**
	 * StringToolKit 构造子注解。
	 */
	public StringUtil() {
		super();
	}

	/**
	 * Sets the stringArrayElement attribute of the StringUtil class
	 *
	 * @param a
	 *            The new stringArrayElement value
	 * @param value
	 *            The new stringArrayElement value
	 * @param index
	 *            The new stringArrayElement value
	 * @return Description of the Return Value
	 */
	public static String[] setStringArrayElement(String[] a, String value, int index) {
		if (index == -1) {
			index = a == null ? 0 : a.length;
		}
		if (index < 0) {
			throw new IllegalArgumentException();
		}
		if (a == null || a.length <= index) {
			String[] old = a;
			a = new String[index + 1];
			if (old != null) {
				System.arraycopy(old, 0, a, 0, old.length);
			}
		}
		a[index] = value;
		return a;
	}

	/**
	 * Gets the arrFromProperties attribute of the StringUtil class
	 *
	 * @param has
	 *            Description of the Parameter
	 * @return The arrFromProperties value
	 */
	public static String[][] getArrFromProperties(Hashtable has) {
		String[][] strArr = new String[0][2];
		// colNames=new String[]{"属性名","属性值"};
		if (has == null) {
			return strArr;
		}
		Enumeration e = has.keys();
		int iLen = 0;
		int row = 0;
		while (e.hasMoreElements()) {
			e.nextElement();
			iLen++;
		}
		strArr = new String[iLen][2];
		Enumeration e1 = has.keys();
		while (e1.hasMoreElements()) {
			Object key = e1.nextElement();
			Object value = has.get(key);
			strArr[row][0] = (String) key;
			strArr[row][1] = (String) value;
			row++;
		}
		return strArr;
	}

	/**
	 * 处理空格
	 *
	 * @param source
	 *            源字符串
	 * @return 处理完成的字符串
	 * @roseuid 3C7EE9500121
	 */
	public static String getContentFromSource(String source) {
		char strTemp;
		StringBuffer strsource = new StringBuffer(source);
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < strsource.length(); i++) {
			strTemp = strsource.charAt(i);
			// 不处理空格符。
			if (strTemp > '\u0019') {
				sb.append(strTemp);
			}
			// if
		}
		String temp = sb.toString();
		sb = null;
		return temp;
	}

	/**
	 * Gets the hastableFromText attribute of the StringUtil object
	 *
	 * @param str
	 *            Description of the Parameter
	 * @param keys
	 *            Description of the Parameter
	 * @param eq
	 *            Description of the Parameter
	 * @return The hastableFromText value
	 */
	public Hashtable getHastableFromText(String str, String keys[], String eq) {
		if (str == null || str.length() <= 0 || keys == null || keys.length <= 0) {
			return null;
		}
		Hashtable has = new Hashtable();
		int iKeysLen = keys.length;
		for (int i = 0; i < iKeysLen; i++) {
			int index = str.indexOf(keys[i]);
			if (index < 0) {
				continue;
			}
			int index_s = str.indexOf("\"", index) + eq.length();
			if (index_s < 0) {
				continue;
			}
			int index_e = str.indexOf("\"", index_s + 1);
			if (index_e < 0 || index_e <= index_s) {
				continue;
			}
			String value = str.substring(index_s, index_e);
			if (value == null) {
				continue;
			}
			has.put(keys[i], value);
		}
		return has;
	}

	/**
	 * Gets the leftDigit attribute of the StringUtil class
	 *
	 * @param str
	 *            Description of the Parameter
	 * @return The leftDigit value
	 */
	public final static String getLeftDigit(String str) {
		return getLeftDigit(str, 0);
	}

	/**
	 * 取出一个字符串中左边数字部分. 例如 getLeftDigit("234XYB34JH") 为 "234"
	 *
	 * @param str
	 *            Description of the Parameter
	 * @param start
	 *            Description of the Parameter
	 * @return The leftDigit value
	 */
	public final static String getLeftDigit(String str, int start) {
		if (str == null) {
			return null;
		}
		str = str.trim();
		int l = str.length();
		if (start > l) {
			return null;
		}
		int i;
		for (i = start; i < l; i++) {
			char c = str.charAt(i);
			if (c < '0' || c > '9') {
				break;
			}
		}
		return str.substring(start, i);
	}

	/**
	 * Gets the substrCount attribute of the StringUtil class
	 *
	 * @param text
	 *            Description of the Parameter
	 * @param subStr
	 *            Description of the Parameter
	 * @return The substrCount value
	 */
	public final static int getSubstrCount(String text, String subStr) {
		if (text == null || text.length() <= 0) {
			return -1;
		}
		int is = 0;
		int ie = 0;
		int rtnCount = 0;
		int iLen = text.length();
		for (is = 0; is < iLen;) {
			ie = text.indexOf(subStr, is);
			if (ie == -1) {
				break;
			}
			is = ie + subStr.length();
			rtnCount++;
		}
		return rtnCount;
	}

	/**
	 * Gets the letter attribute of the StringUtil class
	 *
	 * @param ch
	 *            Description of the Parameter
	 * @return The letter value
	 */
	public static boolean isLetter(char ch) {
		return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z');
	}

	/**
	 * Gets the letterOrDigit attribute of the StringUtil class
	 *
	 * @param ch
	 *            Description of the Parameter
	 * @return The letterOrDigit value
	 */
	public static boolean isLetterOrDigit(char ch) {
		return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9');
	}

	public static boolean HasLetter(String s) {
		char[] cs = s.toCharArray();
		for (int i = 0; i < cs.length; i++) {
			if (isLetter(cs[i]))
				return true;
		}
		return false;
	}

	public static boolean HasSpecialLetter(String s) {
		String ss = "!@#$%^&*()_+-=";
		for (int i = 0; i < ss.length(); i++) {
			if (s.indexOf(ss.charAt(i)) != -1) {
				return true;
			}
		}
		return false;
	}

	/**
	 * 检查一个字符串中是否是一个有效的数值
	 *
	 * @param text
	 *            检查的字符串
	 * @param flags
	 *            位表示的检查选项 bit 1 : 可含'.' , bit 2 :可含',', bit 4 : 可含'-', bit 8 :
	 *            可为空
	 * @return true : 如果检查合法, false : 如果检查不合法
	 */
	public static boolean isValidNumber(String text, int flags) {
		if (text == null || text.trim().length() <= 0) {
			return false;
		}
		int lText = text.length();
		int i = 0;
		for (; i < lText && text.charAt(i) <= ' '; i++) {
			;
		}
		if (i == lText) {
			return (flags & 8) != 0;
		}
		boolean dot = false;
		if (text.charAt(i) == '-') {
			if ((flags & 4) == 0 || ++i >= lText) {
				return false;
			}
		}
		int ndig = 0;
		for (; i < lText; i++) {
			char c = text.charAt(i);
			if (c >= '0' && c <= '9') {
				ndig++;
				continue;
			}
			if (c == ',' && (flags & 2) != 0) {
				continue;
			}
			break;
		}
		if (ndig == 0) {
			return false;
		}
		if (i < lText && text.charAt(i) == '.') {
			if ((flags & 1) == 0) {
				return false;
			}
			i++;
			for (; i < lText; i++) {
				char c = text.charAt(i);
				if (c < '0' || c > '9') {
					break;
				}
			}
		}
		for (; i < lText && text.charAt(i) <= ' '; i++) {
			;
		}
		return i == lText;
	}

	// add by heson 20030605
	/**
	 * 截取字符串的某段长度 @ param str： 要截取的原串 @ param iFrom 起始位置 @ param iTo 结束位置 return
	 * String 截取的字符串
	 *
	 * @param str
	 *            Description of the Parameter
	 * @param iFrom
	 *            Description of the Parameter
	 * @param iTo
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public static String InterceptStr(String str, int iFrom, int iTo) {
		if (iFrom >= 0 && iTo <= str.length()) {
			str = str.substring(iFrom, iTo);
			return str;
		} else {
			return "";
		}
	}

	/**
	 * @param strNumber
	 * @param cont
	 * @return
	 */
	public static String Round(String strNumber, int cont) {
		if (strNumber == null) {
			strNumber = "0";
		}
		BigDecimal number = new BigDecimal(strNumber).movePointRight(cont + 1);
		BigInteger integer = new BigInteger("0");
		if (number.toBigInteger().intValue() % 10 >= 5) {
			integer = number.toBigInteger().add(new BigInteger("10"));
		} else {
			integer = number.toBigInteger();
		}
		integer = integer.divide(new BigInteger("10"));
		number = new BigDecimal(integer, cont);
		return number.toString();
	}

	/**
	 * 字符串分行
	 *
	 * @param str
	 *            要分行的字符串 return String 分行后的字符串
	 * @return Description of the Return Value
	 */
	public static String SplitEnter(String str) {
		String temp = "";
		while (str.indexOf("|") > 0) {
			temp += str.substring(str.indexOf("#") + 1, str.indexOf("|")) + "\n";
			str = str.substring(str.indexOf("|") + 1);
			if (str.indexOf("|") < 0 && str.length() > 0) {
				str = str.substring(str.indexOf("#") + 1);
				temp += str;
			}
		}
		if (temp.length() <= 0) {
			temp = str.substring(str.indexOf("#") + 1);
		}
		return temp;
	}

	/**
	 * 字符串替换
	 *
	 * @param str
	 *            要替换的字符串
	 * @param Rstr
	 *            原字符串
	 * @param Newstr
	 *            新字符串 return String 替换后的字符串
	 * @return Description of the Return Value
	 */
	public static String StrReplace(String str, String Rstr, String Newstr) {
		String strtemp = "";
		if (str.indexOf(Rstr) >= 0) {
			while (str.indexOf(Rstr) >= 0) {
				strtemp += str.substring(0, str.indexOf(Rstr));
				strtemp += Newstr;
				str = str.substring(str.indexOf(Rstr) + Rstr.length());
				if (str.indexOf(Rstr) < 0 && str.length() > 0) {
					strtemp += str;
				}
			}
			return strtemp;
		} else {
			return str;
		}
	}

	/**
	 * Description of the Method
	 *
	 * @param a
	 *            Description of the Parameter
	 * @param key
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public static int binarySearch(Object[][] a, String key) {
		if (a == null) {
			return -1;
		}
		int low = 0;
		int high = a.length - 1;
		while (low <= high) {
			int mid = (low + high) / 2;
			// String midVal = (String)a[mid][0];
			int compare = ((String) a[mid][0]).compareTo(key);
			if (compare < 0) {
				low = mid + 1;
			} else if (compare > 0) {
				high = mid - 1;
			} else {
				return mid;
			}
			// (String)a[mid][1]; // key found
		}
		return -(low + 1);
		// key not found.
	}

	/**
	 * 二元查找法
	 *
	 * @param a
	 *            给定的整形数组
	 * @param key
	 *            待查的元素值
	 * @return 如果查到，返回元素的下标，否则返回-1
	 */
	public static int binarySearch(int[] a, int key) {
		return binarySearch(a, 0, a.length - 1, key);
	}

	/**
	 * 查找字符串
	 *
	 * @param a
	 *            给定的字符数组
	 * @param key
	 *            待查的元素值
	 * @return 如果查到，返回元素的下标，否则返回-1
	 */

	public static int binarySearch(Object[] a, Object key) {
		if (a == null || key == null) {
			return -1;
		}
		int len = a.length;

		for (int i = 0; i < len; i++) {
			if (a[i].equals(key)) {
				return i;
			}
		}
		return -1;
		// Comparator cpt=new Comparator(){
		// public int compare(Object o1, Object o2){
		// String s1=(String)o1;
		// String s2=(String)o2;
		// return s1.compareTo(s2);
		// }
		// public boolean equals(Object obj){
		// return this.equals(obj);
		// }
		// };
		// java.util.Arrays.sort(a,0,a.length-1,cpt);
		// int low = 0;
		// int high = a.length-1;
		//
		// while (low <= high) {
		// int mid = (low + high) >> 1;
		// Object midVal = a[mid];
		// int cmp = cpt.compare(midVal, key);
		//
		// if (cmp < 0)
		// low = mid + 1;
		// else if (cmp > 0)
		// high = mid - 1;
		// else
		// return mid; // key found
		// }
		// return -(low + 1); // key not found.

	}

	/**
	 * @param a
	 * @param low
	 * @param high
	 * @param key
	 * @return
	 */
	public static int binarySearch(int[] a, int low, int high, int key) {
		while (low <= high) {
			int mid = (low + high) / 2;
			int midVal = a[mid];

			if (midVal < key) {
				low = mid + 1;
			} else if (midVal > key) {
				high = mid - 1;
			} else {
				return mid;
			}
			// key found
		}
		return -(low + 1);
		// key not found.
	}

	/**
	 * find index, key<=a[index], key>[index-1]
	 *
	 * @param ncmp
	 *            0:"<", 1:"<=", 2:"=", 3:">=", 4:">"
	 * @param a
	 *            Description of the Parameter
	 * @param low
	 *            Description of the Parameter
	 * @param high
	 *            Description of the Parameter
	 * @param key
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public static int binarySearch(int ncmp, int[] a, int low, int high, int key) {
		while (low < high - 1) {
			int mid = (low + high) >> 1;
			int kcmp = intcmp(key, a[mid]);
			// key < midVal ? -1 : ( key==midVal?0:1 );
			if (kcmp < 0 || (kcmp == 0 && (ncmp == 2 || ncmp == 3 || ncmp == 0))) {
				high = mid;
			} else {
				low = mid;
			}
		}
		if (low > high) {
			return -1;
		}
		if (ncmp >= 2) {
			for (int i = low; i <= high; i++) {
				int k = intcmp(key, a[i]);
				if ((k == 0 && ncmp <= 3) || (k < 0 && ncmp >= 3)) {
					return i;
				}
			}
		} else {
			for (int i = high; i >= low; i--) {
				int k = intcmp(key, a[i]);
				if ((k == 0 && ncmp >= 1) || (k > 0 && ncmp <= 1)) {
					return i;
				}
			}
		}
		return -1;
	}

	/**
	 * Description of the Method
	 *
	 * @param x
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static int countBits(int x) {
		int count = 0;
		for (int i = 0; i < 32; i++) {
			if ((x & (1 << i)) != 0) {
				count++;
			}
		}
		return count;
	}

	/**
	 * Description of the Method
	 *
	 * @param text
	 *            Description of the Parameter
	 * @param iStart
	 *            Description of the Parameter
	 * @param iEnd
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static int countStartSpace(String text, int iStart, int iEnd) {
		int n = 0;
		for (; iStart + n < iEnd; n++) {
			if (!Character.isSpaceChar(text.charAt(iStart + n))) {
				break;
			}
		}
		return n;
	}

	/**
	 * Description of the Method
	 *
	 * @param text
	 *            Description of the Parameter
	 * @param start
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static int countWhitespace(String text, int start) {
		int i = 0;
		for (; start + i < text.length() && Character.isWhitespace(text.charAt(start + i)); i++) {
			;
		}
		return i;
	}

	/**
	 * Description of the Method
	 *
	 * @param str
	 *            Description of the Parameter
	 * @param strEnd
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static String delEnd(String str, String strEnd) {
		return delStarEnd(str, null, strEnd);
	}

	/**
	 * Description of the Method
	 *
	 * @param str
	 *            Description of the Parameter
	 * @param strStar
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static String delStar(String str, String strStar) {
		return delStarEnd(str, strStar, null);
	}

	/**
	 * Description of the Method
	 *
	 * @param str
	 *            Description of the Parameter
	 * @param strStar
	 *            Description of the Parameter
	 * @param strEnd
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static String delStarEnd(String str, String strStar, String strEnd) {
		if ((str == null || str.length() <= 0)
				|| ((strStar == null || strStar.length() <= 0) && (strEnd == null || strEnd.length() <= 0))) {
			return str;
		}
		if (strStar == null) {
			return str.substring(0, str.lastIndexOf(strEnd));
		}
		if (strEnd == null || strEnd.length() <= 0) {
			return str.substring(str.indexOf(strStar) + strStar.length());
		} else {
			return str.substring(str.indexOf(strStar) + strStar.length(), str.lastIndexOf(strEnd));
		}
	}

	/**
	 * Description of the Method
	 *
	 * @param to
	 *            Description of the Parameter
	 * @param from
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static Dictionary dupDictionary(Dictionary to, Dictionary from) {
		if (from == null) {
			return to;
		}
		if (to == null) {
			to = new Hashtable();
		}
		for (Enumeration e = from.keys(); e.hasMoreElements();) {
			Object key = e.nextElement();
			Object val = from.get(key);
			to.put(key, val);
		}
		return to;
	}

	/**
	 * Description of the Method
	 *
	 * @param link
	 *            Description of the Parameter
	 * @param fmt1
	 *            Description of the Parameter
	 * @param fmt2
	 *            Description of the Parameter
	 * @param value
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static String filterFormat(String link, String fmt1, String fmt2, int value[]) {
		if (value == null) {
			return null;
		}
		String r = null;
		for (int i = 0; i < value.length;) {
			int j = i + 1;
			for (; j < value.length && value[j] == value[j - 1] + 1; j++) {
				;
			}
			String s;
			if (j - 1 == i) {
				s = format1(fmt1, Integer.toString(value[i]));
			} else {
				s = format2(fmt2, Integer.toString(value[i]), Integer.toString(value[j - 1]));
			}
			if (i == 0) {
				r = s;
			} else {
				r += ' ' + link + ' ' + s;
			}
			i = j;
		}
		return r;
	}

	/**
	 * Description of the Method
	 *
	 * @param link
	 *            Description of the Parameter
	 * @param fmt1
	 *            Description of the Parameter
	 * @param fmt2
	 *            Description of the Parameter
	 * @param parm
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public static String filterFormat(String link, String fmt1, String fmt2, String parm[]) {
		return filterFormat(link, fmt1, fmt2, parm, false);
	}

	/**
	 * Description of the Method
	 *
	 * @param link
	 *            Description of the Parameter
	 * @param fmt1
	 *            Description of the Parameter
	 * @param fmt2
	 *            Description of the Parameter
	 * @param parm
	 *            Description of the Parameter
	 * @param brackets
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public static String filterFormat(String link, String fmt1, String fmt2, String parm[], boolean brackets) {
		String r = null;
		for (int i = 0; i < parm.length; i++) {
			String s = parm[i].trim();
			int p = fmt2 == null ? -1 : s.indexOf('-');
			if (p > 0) {
				s = format2(fmt2, s.substring(0, p), s.substring(p + 1));
			} else {
				s = format1(fmt1, s);
			}
			if (i == 0) {
				r = s;
			} else {
				r += ' ' + link + ' ' + s;
			}
		}
		return brackets && parm.length > 1 ? "(" + r + ")" : r;
	}

	/**
	 * Description of the Method
	 *
	 * @param link
	 *            Description of the Parameter
	 * @param fmt1
	 *            Description of the Parameter
	 * @param fmt2
	 *            Description of the Parameter
	 * @param parms
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public static String filterFormat(String link, String fmt1, String fmt2, String parms) {
		return filterFormat(link, fmt1, fmt2, splitString(parms, ','), false);
	}

	/**
	 * Description of the Method
	 *
	 * @param link
	 *            Description of the Parameter
	 * @param fmt1
	 *            Description of the Parameter
	 * @param fmt2
	 *            Description of the Parameter
	 * @param parms
	 *            Description of the Parameter
	 * @param brackets
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public static String filterFormat(String link, String fmt1, String fmt2, String parms, boolean brackets) {
		return filterFormat(link, fmt1, fmt2, splitString(parms, ','), brackets);
	}

	/**
	 * Description of the Method
	 *
	 * @param fromArrays
	 *            Description of the Parameter
	 * @param findArrays
	 *            Description of the Parameter
	 * @param bNoCase
	 *            Description of the Parameter
	 * @param bFoundOnly
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static int[] findArrayIndices(String[] fromArrays, String[] findArrays, boolean bNoCase,
			boolean bFoundOnly) {
		int Indices[] = null;
		if (findArrays != null && findArrays.length > 0) {
			Indices = new int[findArrays.length];
			for (int i = 0; i < Indices.length; i++) {
				Indices[i] = -1;
				if (fromArrays != null) {
					for (int j = 0; j < fromArrays.length; j++) {
						if (findArrays[i] != null && fromArrays[j] != null
								&& ((!bNoCase && fromArrays[j].equals(findArrays[i])
										|| (bNoCase && fromArrays[j].equalsIgnoreCase(findArrays[i]))))) {
							Indices[i] = j;
							break;
						}
					}
				}
			}
		}

		if (Indices != null && bFoundOnly) {
			int factNum = 0;
			int len1 = Indices.length;
			for (int i = 0; i < len1; i++) {
				if (Indices[i] >= 0) {
					factNum++;
				}
			}
			if (factNum < len1) {
				int factIndices[] = new int[factNum];
				int pos = 0;
				for (int i = 0; i < len1 && pos < factNum; i++) {
					if (Indices[i] >= 0) {
						factIndices[pos++] = Indices[i];
					}
				}
				return factIndices;
			}
		}
		return Indices;
	}

	/**
	 * 数组中查找整数
	 *
	 * @param a
	 *            Description of the Parameter
	 * @param o
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public static int findAtIntArray(int a[], int o) {
		if (a != null) {
			for (int i = 0; i < a.length; i++) {
				if (o == a[i]) {
					return i;
				}
			}
		}
		return -1;
	}

	/**
	 * 数组中查找字符串
	 *
	 * @param a
	 *            Description of the Parameter
	 * @param o
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public static int findAtStringArray(String a[], Object o) {
		if (a != null) {
			for (int i = 0; i < a.length; i++) {
				if (o == a[i] || (o != null && o.equals(a[i]))) {
					return i;
				}
			}
		}
		return -1;
	}

	/**
	 * 数组中不区分大小写地查找字符串
	 *
	 * @param a
	 *            Description of the Parameter
	 * @param o
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public static int findAtStringArrayNoCase(String a[], String o) {
		if (a != null) {
			for (int i = 0; i < a.length; i++) {
				if (o == a[i] || (o != null && o.equalsIgnoreCase(a[i]))) {
					return i;
				}
			}
		}
		// if(o.equalsIgnoreCase(a[i])) return i;
		return -1;
	}

	/**
	 * Description of the Method
	 *
	 * @param x
	 *            Description of the Parameter
	 * @param minDecimals
	 *            Description of the Parameter
	 * @param maxDecimals
	 *            Description of the Parameter
	 * @param groupingSeparator
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public static String format(double x, int minDecimals, int maxDecimals, boolean groupingSeparator) {
		return format(new BigDecimal(x), minDecimals, maxDecimals, groupingSeparator);
	}

	/**
	 * Description of the Method
	 *
	 * @param fmt
	 *            Description of the Parameter
	 * @param parm
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static String format(String fmt, Object parm[]) {
		String r = new String();
		int l = fmt.length();
		for (int i = 0; i < l;) {
			int p = fmt.indexOf('%', i);
			if (p < i || p >= l - 1) {
				r += fmt.substring(i);
				break;
			}
			// p>=i && p<l-1
			r += fmt.substring(i, p);
			char c = fmt.charAt(p + 1);
			if (c >= '0' && c <= '9') {
				int j = c - '0';
				if (j < parm.length && parm[j] != null) {
					r += parm[j].toString();
				}
				i = p + 2;
			} else if (c == '%') {
				r += '%';
				i = p + 2;
			} else {
				r += '%';
				i = p + 1;
			}
		}
		return r;
	}

	/**
	 * Description of the Method
	 *
	 * @param x
	 *            Description of the Parameter
	 * @param minDecimals
	 *            Description of the Parameter
	 * @param maxDecimals
	 *            Description of the Parameter
	 * @param groupingSeparator
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public static String format(BigDecimal x, int minDecimals, int maxDecimals, boolean groupingSeparator) {

		char tempBuf_64[] = new char[64];
		if (minDecimals <= 0) {
			minDecimals = 2;
		}
		// if( maxDecimals<=0 &&
		if (maxDecimals > 0 && maxDecimals != x.scale()) {
			x = x.setScale(maxDecimals, BigDecimal.ROUND_HALF_UP);
		} else {
			maxDecimals = x.scale();
		}
		String str = x.toString();
		int n = str.length();
		int p = str.indexOf('.');
		if (p < 0) {
			p = n;
		}
		for (; n - 1 - p > minDecimals && n - 1 > p && str.charAt(n - 1) == '0'; n--) {
			;
		}
		int jBuf = 0;
		boolean neg = n > 0 && str.charAt(0) == '-';
		for (int i = 0; i < n; i++) {
			if (groupingSeparator && i > (neg ? 1 : 0) && i < p && (p - i) % 3 == 0) {
				tempBuf_64[jBuf++] = ',';
			}
			tempBuf_64[jBuf++] = str.charAt(i);
		}
		return String.valueOf(tempBuf_64, 0, jBuf);
	}

	/**
	 * Description of the Method
	 *
	 * @param fmt
	 *            Description of the Parameter
	 * @param parm0
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static String format1(String fmt, Object parm0) {
		return format(fmt, new Object[] { parm0 });
	}

	/**
	 * Description of the Method
	 *
	 * @param fmt
	 *            Description of the Parameter
	 * @param parm0
	 *            Description of the Parameter
	 * @param parm1
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static String format2(String fmt, Object parm0, Object parm1) {
		return format(fmt, new Object[] { parm0, parm1 });
	}

	/**
	 * Description of the Method
	 *
	 * @param fmt
	 *            Description of the Parameter
	 * @param parm0
	 *            Description of the Parameter
	 * @param parm1
	 *            Description of the Parameter
	 * @param parm2
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static String format3(String fmt, Object parm0, Object parm1, Object parm2) {
		return format(fmt, new Object[] { parm0, parm1, parm2 });
	}

	/**
	 * Description of the Method
	 *
	 * @param txt
	 *            Description of the Parameter
	 * @param delimiter
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static String formatStr(String txt, char delimiter) {
		StringBuffer strBuf = new StringBuffer();
		if (txt == null || txt.length() <= 0) {
			return txt;
		}
		txt = txt.trim();
		char bt[] = txt.toCharArray();
		for (int i = 0; i < bt.length; i++) {
			if (bt[i] != delimiter) {
				strBuf.append(bt[i]);
			} else {
				if (i > 0) {
					if (bt[i - 1] != delimiter) {
						strBuf.append(bt[i]);
					}
				}
			}
		}
		return strBuf.toString();
	}

	/**
	 * Description of the Method
	 *
	 * @param x
	 *            Description of the Parameter
	 * @param prefix
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static String intToStr2(int x, String prefix) {
		if (prefix == null) {
			prefix = "";
		}
		return x < 10 ? prefix + "0" + x : prefix + x;
	}

	/**
	 * 判断前一个数是否大于后一个数
	 *
	 * @param x
	 *            Description of the Parameter
	 * @param y
	 *            Description of the Parameter
	 * @return 如果前一个数大于后数返回1，如果前一个数等于后一个数返回0，否则返回－1
	 */
	private final static int intcmp(int x, int y) {
		return x < y ? -1 : (x == y ? 0 : 1);
	}

	/**
	 * 判断一个字符串(从某位置起)是否与一含通配符(*,?)的模式串(从某位置起)通配. 例如 like("123A45","1*A??",true)
	 * 为true, like("123A45","1*A???",true) 为 false
	 *
	 * @param text
	 *            被判断的字符串
	 * @param oText
	 *            text的起始位置
	 * @param pattern
	 *            含通配符(*,?)的模式串
	 * @param oPattern
	 *            pattern的起始位置
	 * @param ignoreCase
	 *            是否忽略字母的大小写
	 * @return 是否通配, 如通配,返回 true, 否则 false
	 */
	public static boolean like(String text, int oText, String pattern, int oPattern, boolean ignoreCase) {
		int ltext = text.length() - oText;
		int lpattern = pattern.length() - oPattern;
		for (int i = 0; i < lpattern && i < ltext; i++) {
			char c = pattern.charAt(i + oPattern);
			if (c == '?' || c == '_') {
				continue;
			}
			if (c == '*' || c == '%') {
				if (i == lpattern - 1) {
					return true;
				}
				for (int iText = oText + i; iText < ltext + oText; iText++) {
					if (like(text, iText, pattern, oPattern + i + 1, ignoreCase)) {
						return true;
					}
				}
				return false;
			}
			if (ignoreCase) {
				if (Character.toUpperCase(c) != Character.toUpperCase(text.charAt(oText + i))) {
					return false;
				}
			} else {
				if (c != text.charAt(oText + i)) {
					return false;
				}
			}
		}
		return ltext == lpattern || (lpattern == ltext + 1
				&& (pattern.charAt(lpattern + oPattern - 1) == '*' || pattern.charAt(lpattern + oPattern - 1) == '%'));
	}

	/**
	 * 判断一个字符串是否与一含通配符(*,?)的模式串通配(大小写敏感). 例如 like("123A45","1*A??") 为true,
	 * like("123A45","1*A???") 为 false
	 *
	 * @param text
	 *            被判断的字符串
	 * @param pattern
	 *            含通配符(*,?)的模式串
	 * @return 是否通配, 如通配,返回 true, 否则 false
	 */
	public static boolean like(String text, String pattern) {
		return like(text, 0, pattern, 0, false);
	}

	/**
	 * 判断一个字符串是否与一含通配符(*,?)的模式串通配. 例如 like("123A45","1*A??",true) 为true,
	 * like("123A45","1*A???",true) 为 false
	 *
	 * @param text
	 *            被判断的字符串
	 * @param pattern
	 *            含通配符(*,?)的模式串
	 * @param ignoreCase
	 *            是否忽略字母的大小写
	 * @return 是否通配, 如通配,返回 true, 否则 false
	 */
	public static boolean like(String text, String pattern, boolean ignoreCase) {
		return like(text, 0, pattern, 0, ignoreCase);
	}

	/**
	 * Description of the Method
	 *
	 * @param text
	 *            Description of the Parameter
	 * @param patternlist
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public static boolean likeOneOf(String text, String[] patternlist) {
		return likeOneOf(text, patternlist, false);
	}

	/**
	 * Description of the Method
	 *
	 * @param text
	 *            Description of the Parameter
	 * @param patternlist
	 *            Description of the Parameter
	 * @param ignoreCase
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static boolean likeOneOf(String text, String[] patternlist, boolean ignoreCase) {
		for (int i = 0; i < patternlist.length; i++) {
			if (like(text, 0, patternlist[i], 0, ignoreCase)) {
				return true;
			}
		}
		return false;
	}

	/**
	 * 判断一个字符串是否与一含通配符(*,?)的若干模式串(用逗号分开)中的一个通配(大小写敏感). 例如
	 * like("123A45","1*B??,1*A??",true) 为true,
	 * like("123A45","1*B??,1*A???",true) 为 false
	 *
	 * @param text
	 *            被判断的字符串
	 * @param pattern
	 *            含通配符(*,?)的若干模式串(用逗号分开)
	 * @return 是否通配, 如通配,返回 true, 否则 false
	 */
	public static boolean likeOneOf(String text, String pattern) {
		return likeOneOf(text, pattern, false);
	}

	/**
	 * Description of the Method
	 *
	 * @param text
	 *            Description of the Parameter
	 * @param pattern
	 *            Description of the Parameter
	 * @param deli
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public static boolean likeOneOf(String text, String pattern, char deli) {
		return likeOneOf(text, pattern, deli, (String) null, (String) null, false);
	}

	/**
	 * 判断一个字符串是否与一含通配符(*,?)的若干模式串(用逗号分开)中的一个(加上前后缀)通配. 例如
	 * like("123A45","1*B??,1*A??",true) 为true,
	 * like("123A45","1*B??,1*A???",true) 为 false
	 *
	 * @param text
	 *            被判断的字符串
	 * @param pattern
	 *            含通配符(*,?)的若干模式串(用deli分开),
	 * @param deli
	 *            pattern中的分割符
	 * @param patternPrifix
	 *            前缀
	 * @param patternSuffix
	 *            后缀
	 * @param ignoreCase
	 *            是否忽略字母的大小写
	 * @return 是否通配, 如通配,返回 true, 否则 false
	 */
	public static boolean likeOneOf(String text, String pattern, char deli, String patternPrifix, String patternSuffix,
			boolean ignoreCase) {
		if (patternPrifix == null) {
			patternPrifix = "";
		}
		if (patternSuffix == null) {
			patternSuffix = "";
		}
		String patternlist[] = splitString(pattern, deli);
		for (int i = 0; i < patternlist.length; i++) {
			if (like(text, 0, patternPrifix + patternlist[i] + patternSuffix, 0, ignoreCase)) {
				return true;
			}
		}
		return false;
	}

	/**
	 * 判断一个字符串是否与一含通配符(*,?)的若干模式串(用逗号分开)中的一个(加上前后缀)通配. 例如
	 * like("123A45","1*B??,1*A??",true) 为true,
	 * like("123A45","1*B??,1*A???",true) 为 false
	 *
	 * @param text
	 *            被判断的字符串
	 * @param pattern
	 *            含通配符(*,?)的若干模式串(用逗号分开),
	 * @param patternPrifix
	 *            前缀
	 * @param patternSuffix
	 *            后缀
	 * @param ignoreCase
	 *            是否忽略字母的大小写
	 * @return 是否通配, 如通配,返回 true, 否则 false
	 */
	public static boolean likeOneOf(String text, String pattern, String patternPrifix, String patternSuffix,
			boolean ignoreCase) {
		return likeOneOf(text, pattern, ',', patternPrifix, patternSuffix, ignoreCase);
	}

	/**
	 * 判断一个字符串是否与一含通配符(*,?)的若干模式串(用逗号分开)中的一个通配. 例如
	 * like("123A45","1*B??,1*A??",true) 为true,
	 * like("123A45","1*B??,1*A???",true) 为 false
	 *
	 * @param text
	 *            被判断的字符串
	 * @param pattern
	 *            含通配符(*,?)的若干模式串(用逗号分开)
	 * @param ignoreCase
	 *            是否忽略字母的大小写
	 * @return 是否通配, 如通配,返回 true, 否则 false
	 */
	public static boolean likeOneOf(String text, String pattern, boolean ignoreCase) {
		return likeOneOf(text, splitString(pattern, ','), ignoreCase);
	}

	/**
	 * 根据所给的值查找相对的位置
	 *
	 * @param a
	 *            待查找的整形数组
	 * @param key
	 *            给定的元素值
	 * @return 如果没找到 返回-1 否则，返回此元素在此数组里的下标
	 */
	public static int linearSearch(int[] a, int key) {
		if (a != null) {
			for (int i = 0; i < a.length; i++) {
				if (a[i] == key) {
					return i;
				}
			}
		}
		return -1;
	}

	/**
	 * 输入流中是一组键值表，从中装入这些键值表并写入属性字典.
	 *
	 * @param props
	 *            属性字典
	 * @param in
	 *            键值表的输入流
	 * @exception IOException
	 *                Description of the Exception
	 */
	public static synchronized void loadProperties(Dictionary props, BufferedReader in) throws IOException {
		// 1.1

		if (in == null) {
			return;
		}
		for (;;) {
			String lineText = in.readLine();
			if (lineText == null) {
				break;
			}
			if (lineText.length() == 0 || lineText.charAt(0) == '#' || lineText.charAt(0) == '!') {
				continue;
			}
			putProperty(props, lineText);
		}
	}

	/**
	 * yueqianlong 2002-11-26号注释掉此行 输入流中是一组键值表，从中装入这些键值表并写入属性字典. 例子 ： 从资源
	 * mywork.properties 中装入键值表(mywork.properties每行为 <key>=<value> 的形式)
	 * <blockquote>
	 * 
	 * <pre>
	 * Hashtable appProperties = new Hashtable(); java.io.InputStream input =
	 * mywork.Main.class.getResourceAsStream("mywork.properties");
	 * StringUtil.loadProperties(appProperties,input);
	 *
	 *
	 *
	 *
	 *
	 *
	 * @param props
	 *            属性字典
	 * @param inStream
	 *            键值表的输入流
	 */
	public static synchronized void loadProperties(Dictionary props, InputStream inStream) {
		if (inStream == null) {
			return;
		}
		// loadProperties( props, new BufferedReader(new
		// PreprocessedTextReader(new InputStreamReader(inStream)))
		// );//yueqianlong 2002-11-26号注释掉此行
	}

	/**
	 * 从属性字典装载所有键名以prefix为前缀的属性值.
	 *
	 * @param props
	 *            属性字典
	 * @param prefix
	 *            给定的前缀
	 * @return 所有键名以prefix为前缀的属性值
	 */
	public final static String[] loadProperties(Dictionary props, String prefix) {
		Vector a = new Vector();
		// 1.1
		int lPrefix = prefix.length();
		for (Enumeration e = props.keys(); e.hasMoreElements();) {
			String key = (String) e.nextElement();
			if (key.startsWith(prefix)) {
				a.addElement(key.substring(lPrefix));
				// 1.1
				a.addElement(props.get(key));
			}
		}
		int n = a.size();
		String s[] = new String[n];
		for (int i = 0; i < n; i++) {
			s[i] = (String) a.elementAt(i);
		}
		return s;
	}

	/**
	 * 从属性字典装载所有键名以prefix为前缀的属性到另一属性字典.
	 *
	 * @param from
	 *            源属性字典
	 * @param to
	 *            目标属性字典
	 * @param prefix
	 *            给定的前缀
	 * @return 拷贝的个数
	 */
	public final static int loadProperties(Dictionary from, Dictionary to, String prefix) {
		int lPrefix = prefix.length();
		int count = 0;
		for (Enumeration e = from.keys(); e.hasMoreElements();) {
			String key = (String) e.nextElement();
			if (key.startsWith(prefix)) {
				to.put(key.substring(lPrefix), from.get(key));
				count++;
			}
		}
		return count;
	}

	/**
	 * 此函数用于字符串中的宏替换
	 *
	 * @param text
	 *            代处理的字符串
	 * @param macro
	 *            用以宏定义的哈希表
	 * @return 返回的结果
	 */
	public static String macroReplace(String text, Hashtable macro) {
		Enumeration e = macro.keys();
		while (e.hasMoreElements()) {
			String str = (String) e.nextElement();
			if (str == null || str.length() <= 0 || text.indexOf(str) < 0) {
				continue;
			} else {
				text = strReplace(text, str, (String) macro.get(str));
			}
		}
		return text;
	}


	/**
	 * Description of the Method
	 *
	 * @param iArr
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public static Integer maxInt(Integer iArr[]) {
		if (iArr == null || iArr.length <= 0) {
			return null;
		}
		Integer rtn = iArr[0];
		for (int i = 1; i < iArr.length; i++) {
			if (rtn.intValue() > iArr[i].intValue()) {
				continue;
			}
			if (rtn.intValue() < iArr[i].intValue()) {
				rtn = iArr[i];
				continue;
			}
		}
		return rtn;
	}

	/**
	 * 返回三位数的中大小为中间的那位数的值；
	 *
	 * @param x
	 * @param a
	 * @param b
	 * @param c
	 * @return
	 */
	private static int med3(int x[], int a, int b, int c) {
		return (x[a] < x[b] ? (x[b] < x[c] ? b : x[a] < x[c] ? c : a) : (x[b] > x[c] ? b : x[a] > x[c] ? c : a));
	}

	/**
	 * Description of the Method
	 *
	 * @param src
	 *            Description of the Parameter
	 * @param dest
	 *            Description of the Parameter
	 * @param low
	 *            Description of the Parameter
	 * @param high
	 *            Description of the Parameter
	 * @param bSortInc
	 *            Description of the Parameter
	 */
	private static void mergeSort(String src[], String dest[], int low, int high, boolean bSortInc) {
		int length = high - low;

		if (length < 7) {
			for (int i = low; i < high; i++) {
				for (int j = i; j > low && ((bSortInc && dest[j - 1].compareTo(dest[j]) > 0)
						|| (!bSortInc && dest[j - 1].compareTo(dest[j]) < 0)); j--) {
					swap(dest, j, j - 1);
				}
			}
			return;
		}

		int mid = (low + high) / 2;
		mergeSort(dest, src, low, mid, bSortInc);
		mergeSort(dest, src, mid, high, bSortInc);

		if ((bSortInc && src[mid - 1].compareTo(src[mid]) <= 0)
				|| (!bSortInc && src[mid - 1].compareTo(src[mid]) >= 0)) {
			System.arraycopy(src, low, dest, low, length);
			return;
		}

		for (int i = low, p = low, q = mid; i < high; i++) {
			if (q >= high || p < mid
					&& ((bSortInc && src[p].compareTo(src[q]) <= 0) || (!bSortInc && src[p].compareTo(src[q]) >= 0))) {
				dest[i] = src[p++];
			} else {
				dest[i] = src[q++];
			}
		}
	}

	/**
	 * Description of the Method
	 *
	 * @param iArr
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public static Integer minInt(Integer iArr[]) {
		if (iArr == null || iArr.length <= 0) {
			return null;
		}
		Integer rtn = iArr[0];
		for (int i = 1; i < iArr.length; i++) {
			if (rtn.intValue() < iArr[i].intValue()) {
				continue;
			}
			if (rtn.intValue() > iArr[i].intValue()) {
				rtn = iArr[i];
				continue;
			}
		}
		return rtn;
	}

	/**
	 * 取得一个元素在Object[]的下标
	 *
	 * @param obs
	 *            Object数组
	 * @param ob
	 *            要查找的数组的元素
	 * @return 返回找到的元素在数组的下标，如果没找到，则返回－1
	 */
	public static int objInObjArray(Object[] obs, Object ob) {
		if (obs != null && ob != null) {
			try {
				for (int i = 0; i < obs.length; i++) {
					if (obs[i] == ob) {
						return i;
					}
				}
			} catch (Exception e) {
			}
		}
		return -1;
	}

	/**
	 * Description of the Method
	 *
	 * @param o1
	 *            Description of the Parameter
	 * @param o2
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public static boolean objectEquals(Object o1, Object o2) {
		if (o1 == o2) {
			return true;
		}
		return o1 != null && o1.equals(o2);
	}

	/**
	 * 参数表分析. 例如 <blockquote>
	 * 
	 * <pre>
	 *   String list[] = new String[64];
	 *   parseParameterList("M(XXX1,XXX2,XXX3)",1,list)
	 *    //  返回结果为3 , list[0] = "XXX1", list[1] = "XXX2", list[2] = "XXX3"
	 * </pre>
	 * 
	 * </blockquote>
	 *
	 * @param text
	 *            含参数表的字符串
	 * @param iStart
	 *            参数表在text中的起始位置(该位置除空格外的第一个必须为'('),
	 * @param list
	 *            参数分析出的结果放在其中(必须保证list元素个数足够大)
	 * @return 参数在text中的长度
	 */
	public final static int parseParameterList(String text, int iStart, String[] list) {
		// text : (XXX,XXX,XXX)

		for (int i = 0; i < list.length;) {
			list[i++] = null;
		}
		int jStack = 0;
		int ltext = text.length();
		int nList = 0;
		int n = countStartSpace(text, iStart, ltext);
		if (n >= ltext || text.charAt(iStart + n) != '(') {
			return 0;
		}
		n++;
		// skip '(' ')'
		n += countStartSpace(text, iStart + n, ltext);
		char charStr = 0;
		int i0 = n;
		for (; n < ltext;) {
			char c = text.charAt(iStart + n);
			if (c == '"' || c == '\'') {
				if (charStr == 0) {
					charStr = c;
				} else if (c == charStr && text.charAt(iStart + n - 1) != '\\') {
					charStr = 0;
				}
			}
			if (charStr != 0) {
				n++;
				continue;
			}
			if (jStack == 0 && (c == ',' || c == ')')) {
				String s = text.substring(iStart + i0, iStart + n);
				list[nList++] = s.trim();
				n++;
				if (c == ')') {
					break;
				}
				i0 = n += countStartSpace(text, iStart + n, ltext);
				continue;
			}
			if (c == ')') {
				jStack--;
			} else if (c == '(') {
				jStack++;
			}
			n++;
		}
		return n;
	}

	/**
	 * Description of the Method
	 *
	 * @param valueText
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static Object parseValue(String valueText) {
		if (valueText == null) {
			return null;
		}
		valueText = valueText.trim();
		int lvalueText = valueText.length();
		if (lvalueText == 0) {
			return null;
		}
		char c0 = valueText.charAt(0);
		if ((c0 >= '0' && c0 <= '9') || c0 == '-') {
			if (valueText.indexOf('.') > 0) {
				return Double.valueOf(valueText);
			}
			if (c0 == '-') {
				valueText = valueText.substring(1);
				lvalueText--;
			}
			char c1 = valueText.charAt(0);
			char c2 = lvalueText > 1 ? valueText.charAt(1) : 0;
			int x = 0;
			if (c1 == '0' && (c2 == 'x' || c2 == 'X')) {
				x = Integer.parseInt(valueText.substring(2), 16);
			} else {
				x = Integer.parseInt(valueText);
			}
			return new Integer(c0 == '-' ? -x : x);
		}
		if (c0 == '"' && lvalueText >= 2 && valueText.charAt(lvalueText - 1) == '"') {
			return replaceEscapeChar(valueText.substring(1, lvalueText - 1));
		}
		if (c0 == '\'' && lvalueText >= 2 && valueText.charAt(lvalueText - 1) == '\'') {
			return new Character(valueText.charAt(1));
		}
		if (valueText.equals("true")) {
			return Boolean.TRUE;
		}
		if (valueText.equals("false")) {
			return Boolean.FALSE;
		}
		return null;
	}

	// static public synchronized void loadProperties(Map props,BufferedReader
	// in) throws IOException // 1.2

	/**
	 * 分析一段形式为<key>=<value>的键值对并写入属性字典.
	 *
	 * @param props
	 *            属性字典
	 * @param text
	 *            形式为<key>=<value>的键值对,如"SystemList=00:系统维护,01:帐务系统,02:报表系统,03:工资系统,04:固定资产,05:05表,06:利息计算,07:辅助核算,08:合同核算,09:查询系统,10:工具"
	 * @return text中的键名
	 */
	public static String putProperty(Dictionary props, String text) {
		if (text == null) {
			return null;
		}
		int p = text.indexOf('=');
		if (p <= 0) {
			return null;
		}
		String name = text.substring(0, p).trim();
		if (name.length() == 0) {
			return null;
		}
		String value = text.substring(p + 1).trim();
		props.put(name, value);
		return name;
	}

	/**
	 * 检验数组下表越界的异常
	 *
	 * @param arrayLen
	 *            数组的长度
	 * @param fromIndex
	 *            起始位置
	 * @param toIndex
	 *            结束位置
	 */
	private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) {
		if (fromIndex > toIndex) {
			throw new IllegalArgumentException("fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")");
		}
		if (fromIndex < 0) {
			throw new ArrayIndexOutOfBoundsException(fromIndex);
		}
		if (toIndex > arrayLen) {
			throw new ArrayIndexOutOfBoundsException(toIndex);
		}
	}

	/**
	 * 将一个字符串头尾的括号去掉. <blockquote>
	 * 
	 * <pre>
	 *    String text = removeBrackets("[abcdefg]",'[',']');
	 *       	 *           	 *        *           	 *	  // 结果为 "abcdefg"
	 * </pre>
	 * 
	 * </blockquote>
	 *
	 * @param text
	 *            头尾带括号的字符串
	 * @param head
	 *            头括号字符,如 '[','(','{' 等
	 * @param tail
	 *            尾括号字符,如 ']',')','}' 等
	 * @return text头尾去掉括号后的结果(中间的括号忽略)
	 */
	public final static String removeBrackets(String text, char head, char tail) {
		if (text == null) {
			return text;
		}
		int len = text.length();
		return text.charAt(0) == head && text.charAt(len - 1) == tail ? text.substring(1, len - 1) : text;
	}

	/**
	 * 将 Access 风格的 通配符(*,?)替换为(%,_) .
	 *
	 * @param text
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static String replaceAccessStyleSqlPattern(String text) {
		return text == null ? null : text.replace('*', '%').replace('?', '_');
	}

	/**
	 * @param txt
	 *            原字符串
	 * @param scr
	 *            Description of the Parameter
	 * @param dec
	 *            Description of the Parameter
	 * @return
	 */
	public static String replaceAll(String txt, String scr, String dec) {
		if (txt == null || txt.length() <= 0 || scr == null || dec == null) {
			return txt;
		}
		while (txt.indexOf(scr) >= 0) {
			txt = txt.substring(0, txt.indexOf(scr)) + dec + txt.substring(txt.indexOf(scr) + scr.length());
		}
		return txt;
	}

	/**
	 * 将一个字符串中某字符替换为另外一个字符. 例如
	 * <code> replaceChar("\\mywork\\sndata\\file1.txt",'\\','/') </code> 的结果为
	 * "/mywork/ndata/file1.txt"
	 *
	 * @param text
	 *            被替换的字符串
	 * @param charFrom
	 *            text中被替换的字符
	 * @param charTo
	 *            替换的字符
	 * @return 替换后的结果
	 */
	public final static String replaceChar(String text, char charFrom, char charTo) {
		if (text == null || text.indexOf(charFrom) < 0) {
			return text;
		}
		StringBuffer strBuffer = new StringBuffer();
		for (int i0 = 0; i0 < text.length();) {
			int i = text.indexOf(charFrom, i0);
			if (i < 0) {
				strBuffer.append(text.substring(i0));
				break;
			} else {
				strBuffer.append(text.substring(i0, i));
				strBuffer.append(charTo);
				i0 = i + 1;
			}
		}
		return strBuffer.toString();
	}

	/**
	 * 替换 \", \r, \n, \t, \\ 等
	 *
	 * @param text
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static String replaceEscapeChar(String text) {
		if (text == null) {
			return text;
		}
		StringBuffer textBuffer = new StringBuffer();
		int n = text.length();
		int m = 0;
		for (int i = 0; i < n; i++) {
			char c = text.charAt(i);
			if (c == '\\' && ++i < n) {
				m++;
				char c2 = text.charAt(i);
				if (c2 == 'n') {
					c = '\n';
				} else if (c2 == 'r') {
					c = '\r';
				} else {
					c = c2;
				}
			}
			textBuffer.append(c);
		}
		return m == 0 ? text : textBuffer.toString();
	}

	/**
	 * @param size
	 * @param weight
	 * @param jFrom
	 * @param jTo
	 * @param sizeFitTo
	 */
	public static void resizeToFit(int size[], int weight[], int jFrom, int jTo, int sizeFitTo) {
		int totalWeight = 0;
		// int nTotalToberesize = 0;
		int totalWeightP = 0;
		int nTotalP = 0;
		int totalSize = 0;
		// int jLast = 0;
		for (int j = jFrom; j <= jTo; j++) {
			totalWeight += weight[j];
			totalSize += size[j];
			if (size[j] > 1) {
				totalWeightP += weight[j];
				nTotalP++;
			}
		}
		int deltaResize = sizeFitTo - totalSize;
		// 放大/变小 量
		if (deltaResize == 0) {
			return;
		}
		int nTotalToberesize = jTo - jFrom + 1;
		if (deltaResize < 0) {
			nTotalToberesize = nTotalP;
			totalWeight = totalWeightP;
			// 缩小时不考虑 size[j]<=1 的
		}
		if (nTotalToberesize <= 0) {
			return;
		}
		int d = deltaResize;
		int nResizedCount = 0;
		for (int j = jFrom; j <= jTo; j++) {
			if (j == jTo && deltaResize > 0) {
				size[j] += d;
				return;
			}
			int tmpWeight = weight[j];
			int tmpTotalWeight = totalWeight;
			if (tmpTotalWeight == 0) {
				tmpTotalWeight = nTotalToberesize;
				tmpWeight = 1;
			}
			int sz = (tmpWeight * deltaResize) / tmpTotalWeight;
			if (size[j] + sz < 1) {
				sz = 1 - size[j];
			}
			if (sz != 0) {
				size[j] += sz;
				d -= sz;
				nResizedCount++;
			}
		}
		if (d != 0 && nResizedCount > 0 && deltaResize < 0) {
			resizeToFit(size, weight, jFrom, jTo, sizeFitTo);
		}
	}

	/**
	 * @param a
	 * @param fromIndex
	 * @param toIndex
	 * @param bSortInc
	 */
	public static void sort(int[] a, int fromIndex, int toIndex, boolean bSortInc) {
		rangeCheck(a.length, fromIndex, toIndex);
		sort1(a, fromIndex, toIndex - fromIndex, bSortInc);
	}

	/**
	 * Description of the Method
	 *
	 * @param a
	 *            Description of the Parameter
	 * @param bSortInc
	 *            Description of the Parameter
	 */
	public static void sort(int[] a, boolean bSortInc) {
		sort1(a, 0, a.length, bSortInc);
	}

	/**
	 * Description of the Method
	 *
	 * @param a
	 *            Description of the Parameter
	 * @param fromIndex
	 *            Description of the Parameter
	 * @param toIndex
	 *            Description of the Parameter
	 * @param bSortInc
	 *            Description of the Parameter
	 */
	public static void sort(String[] a, int fromIndex, int toIndex, boolean bSortInc) {
		rangeCheck(a.length, fromIndex, toIndex);
		String aux[] = a.clone();
		mergeSort(aux, a, fromIndex, toIndex, bSortInc);
	}

	/**
	 * if bSortInc is true, sort the arrays inc, else sort the arrays dec add by
	 * grant
	 *
	 * @param a
	 *            Description of the Parameter
	 * @param bSortInc
	 *            Description of the Parameter
	 */
	public static void sort(String[] a, boolean bSortInc) {
		String aux[] = a.clone();
		mergeSort(aux, a, 0, a.length, bSortInc);
	}

	/**
	 * Description of the Method
	 *
	 * @param x
	 *            Description of the Parameter
	 * @param off
	 *            Description of the Parameter
	 * @param len
	 *            Description of the Parameter
	 * @param bSortInc
	 *            Description of the Parameter
	 */
	private static void sort1(int x[], int off, int len, boolean bSortInc) {
		if (len < 7) {
			for (int i = off; i < len + off; i++) {
				for (int j = i; j > off && ((bSortInc && x[j - 1] > x[j]) || (!bSortInc && x[j - 1] < x[j])); j--) {
					swap(x, j, j - 1);
				}
			}
			return;
		}

		int m = off + len / 2;
		if (len > 7) {
			int l = off;
			int n = off + len - 1;
			if (len > 40) {
				// Big arrays, pseudomedian of 9
				int s = len / 8;
				l = med3(x, l, l + s, l + 2 * s);
				m = med3(x, m - s, m, m + s);
				n = med3(x, n - 2 * s, n - s, n);
			}
			m = med3(x, l, m, n);
			// Mid-size, med of 3
		}
		int v = x[m];

		// Establish Invariant: v* (<v)* (>v)* v*
		int a = off;

		// Establish Invariant: v* (<v)* (>v)* v*
		int b = a;

		// Establish Invariant: v* (<v)* (>v)* v*
		int c = off + len - 1;

		// Establish Invariant: v* (<v)* (>v)* v*
		int d = c;
		if (bSortInc) {
			while (true) {
				while (b <= c && x[b] <= v) {
					if (x[b] == v) {
						swap(x, a++, b);
					}
					b++;
				}
				while (c >= b && x[c] >= v) {
					if (x[c] == v) {
						swap(x, c, d--);
					}
					c--;
				}
				if (b > c) {
					break;
				}
				swap(x, b++, c--);
			}
		} else {
			while (true) {
				while (b <= c && x[b] >= v) {
					if (x[b] == v) {
						swap(x, a++, b);
					}
					b++;
				}
				while (c >= b && x[c] <= v) {
					if (x[c] == v) {
						swap(x, c, d--);
					}
					c--;
				}
				if (b > c) {
					break;
				}
				swap(x, b++, c--);
			}
		}

		// Swap partition elements back to middle
		int s;

		// Swap partition elements back to middle
		int n = off + len;
		s = Math.min(a - off, b - a);
		vecswap(x, off, b - s, s);
		s = Math.min(d - c, n - d - 1);
		vecswap(x, b, n - s, s);

		// Recursively sort non-partition-elements
		if ((s = b - a) > 1) {
			sort1(x, off, s, bSortInc);
		}
		if ((s = d - c) > 1) {
			sort1(x, n - s, s, bSortInc);
		}
	}

	/**
	 * 将一个一维数组根据每个元素的分割字符分成一个二维数组
	 *
	 * @param strArr
	 *            一维数组
	 * @param split
	 *            二维数组
	 * @return
	 */
	public static String[][] splitStrArr(String[] strArr, char split) {
		if (strArr == null) {
			return null;
		}
		int iLen = strArr.length;
		if (iLen <= 0) {
			return null;
		}
		String[][] rtnArr = new String[2][iLen];

		for (int i = 0; i < iLen; i++) {
			rtnArr[0][i] = strArr[i].substring(0, strArr[i].indexOf(split));
			rtnArr[1][i] = strArr[i].substring(strArr[i].indexOf(split) + 1);
		}
		return rtnArr;
	}

	/**
	 * 将一个字符串以某字符作为分隔符进行分隔(得到每段作为字符串的字符串数组).
	 *
	 * @param str
	 *            被分隔的字符串
	 * @param delimiter
	 *            分隔符
	 * @return 分隔的结果
	 */
	public final static String[] splitString(String str, char delimiter) {
		return splitString(str, 0, delimiter);
	}

	/**
	 * Description of the Method
	 *
	 * @param str
	 *            Description of the Parameter
	 * @param delimiter1
	 *            Description of the Parameter
	 * @param delimiter2
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static String[][] splitString(String str, char delimiter1, char delimiter2) {
		String[] a1 = splitString(str, delimiter1);
		if (a1 == null) {
			return null;
		}
		String a2[][] = new String[a1.length][];
		for (int i = 0; i < a1.length; i++) {
			a2[i] = splitString(a1[i], delimiter2);
		}
		return a2;
	}

	/**
	 * 将一个字符串从某位置开始以某字符作为分隔符进行分隔(得到每段作为字符串的字符串数组). <blockquote>
	 * 
	 * <pre>
	 *     String list[] = StringUtil.splitString("AAAA,BBBB,CCCC,DDDDD",0,',')
	 *     // list 为  { "AAAA","BBBB","CCCC","DDDD" }
	 * </pre>
	 * 
	 * </blockquote>
	 *
	 * @param str
	 *            被分隔的字符串
	 * @param istart
	 *            开始位置
	 * @param delimiter
	 *            分隔符
	 * @return 分隔的结果
	 */
	public final static String[] splitString(String str, int istart, char delimiter) {
		if (str == null) {
			return null;
		}
		int sl = str.length();
		int n = 0;
		for (int i = istart; i < sl; i++) {
			if (str.charAt(i) == delimiter) {
				n++;
			}
		}
		String[] sa = new String[n + 1];
		int i = istart;
		int j = 0;
		for (; i < sl;) {
			int iend = str.indexOf(delimiter, i);
			if (iend < 0) {
				break;
			}
			sa[j++] = str.substring(i, iend);
			i = iend + 1;
		}
		sa[j++] = str.substring(i);
		return sa;
	}

	/**
	 * 拆粉字符串
	 *
	 * @param src
	 *            Description of the Parameter
	 * @param reg
	 *            Description of the Parameter
	 * @return 拆分后的数组
	 * @roseuid 3C7EE9500121
	 */
	public final static String[] splitString(String src, String reg) {
		int i = 0;
		String EMPTY_STRING = "EMPTY";
		i = src.indexOf(reg + reg);
		while (i != -1) {
			src = src.substring(0, i) + reg + EMPTY_STRING + reg + src.substring(i + 2, src.length());
			i = src.indexOf(reg + reg);
		}
		if (src.charAt(0) == reg.charAt(0)) {
			src = EMPTY_STRING + src;
		}
		if (src.charAt(src.length() - 1) == reg.charAt(0)) {
			src = src + EMPTY_STRING;
		}
		java.util.StringTokenizer st = new java.util.StringTokenizer(src, reg);
		Vector v = new Vector();
		while (st.hasMoreTokens()) {
			v.addElement(st.nextToken());
		}
		String[] sa = new String[v.size()];
		for (i = 0; i < v.size(); i++) {
			sa[i] = new String(v.elementAt(i).toString());
			if (sa[i].equals(EMPTY_STRING)) {
				sa[i] = "";
			}
		}
		v = null;
		return sa;
	}

	/**
	 * Description of the Method
	 *
	 * @param text
	 *            Description of the Parameter
	 * @param delimiter
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static Vector splitStringToVec(String text, String delimiter) {
		if (text == null || text.length() <= 0) {
			return null;
		}
		int iLen = text.length();
		Vector vec = new Vector();
		int is = 0;
		int ie = 0;
		for (; is < iLen;) {
			ie = text.indexOf(delimiter, is);
			if (ie < 0) {
				if (is < iLen) {
					vec.addElement(text.substring(is));
					break;
				}
			}
			vec.addElement(text.substring(is, ie));
			is = ie + delimiter.length();
			if (ie >= iLen) {
				break;
			}
		}
		return vec;
	}

	/**
	 * Description of the Method
	 *
	 * @param s
	 *            Description of the Parameter
	 * @param charBefore
	 *            Description of the Parameter
	 * @param negEnable
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public static int startWithInt(String s, char charBefore, boolean negEnable) {
		int p = s.indexOf(charBefore);
		if (p <= 0) {
			return p;
		}
		int i = 0;
		if (negEnable && s.charAt(0) == '-') {
			i++;
		}
		for (; i < p; i++) {
			char c = s.charAt(i);
			if (c < '0' || c > '9') {
				return -1;
			}
		}
		return p;
	}

	/**
	 * 此函数用于将字符串中的宏定义字符串替换成指定的字符串
	 *
	 * @param text
	 *            要处理的字符串
	 * @param strmacro
	 *            宏定义字符串
	 * @param str
	 *            指定的字符串
	 * @return 返回结果
	 */
	public static String strReplace(String text, String strmacro, String str) {
		if (text == null || text.length() <= 0) {
			return text;
		}
		int index = -1;
		index = text.indexOf(strmacro);
		if (index >= 0) {
			text = text.substring(0, index) + str + text.substring(index + strmacro.length());
			return strReplace(text, strmacro, str);
		} else {
			return text;
		}
	}

	/**
	 * 字符串连接
	 *
	 * @param s1
	 * @param s2
	 * @return
	 */
	public final static String strcat(String s1, String s2) {
		return s1 != null && s2 != null ? s1 + s2 : (s1 == null ? s2 : s1);
	}

	/**
	 * Description of the Method
	 *
	 * @param s1
	 *            Description of the Parameter
	 * @param s2
	 *            Description of the Parameter
	 * @param deli
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static String strcat(String s1, String s2, String deli) {
		return s1 != null && s2 != null ? s1 + deli + s2 : (s1 == null ? s2 : s1);
	}

	/*
	 * StringUtil.stringConnect(" where %0=?"," and %0=?",new
	 * String[]{"a","b","c"}); 结果 " where a=? and b=? and c=?"
	 */
	/**
	 * Description of the Method
	 *
	 * @param firstFormat
	 *            Description of the Parameter
	 * @param otherFormat
	 *            Description of the Parameter
	 * @param parm
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static String stringConnect(String firstFormat, String otherFormat, Object parm[]) {
		String text = format1(firstFormat, parm[0]);
		for (int i = 1; i < parm.length; i++) {
			text += format1(otherFormat, parm[i]);
		}
		return text;
	}

	/**
	 * 重复一个字符 n 次得到一个字符串. 例如stringFromDupChar('0',5)为"00000"
	 *
	 * @param c
	 *            Description of the Parameter
	 * @param n
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static String stringFromDupChar(char c, int n) {
		StringBuffer strBuffer = new StringBuffer();
		for (; n > 0; n--) {
			strBuffer.append(c);
		}
		return new String(strBuffer);
	}

	/*
	 * 得到一个字符串中某字符分隔出的左边部分,如不含
	 */
	/**
	 * Description of the Method
	 *
	 * @param str
	 *            Description of the Parameter
	 * @param c
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static String stringLeft(String str, char c) {
		if (str == null) {
			return null;
		}
		int p = str.indexOf(c);
		return p >= 0 ? str.substring(0, p) : str;
	}

	/**
	 * 将一个字符串以某字符作为分隔符进行分隔后取其中某一段. <blockquote>
	 * 
	 * <pre>
	 *     String subtext = StringUtil.splitString("AAAA,BBBB,CCCC,DDDDD",',',2)
	 *     // subtext 为 "CCCC"
	 * </pre>
	 * 
	 * </blockquote>
	 *
	 * @param str
	 *            被分隔的字符串
	 * @param delimiter
	 *            分隔符
	 * @param index
	 *            分隔后的子串数组下标
	 * @return 第 index 个子串
	 */
	public final static String subSplitString(String str, char delimiter, int index) {
		return subSplitString(str, 0, delimiter, index);
	}

	/**
	 * 将一个字符串以某字符作为分隔符进行分隔后取其中某一段. <blockquote>
	 * 
	 * <pre>
	 *     String subtext = StringUtil.splitString("AAAA,BBBB,CCCC,DDDDD",0,',',2)
	 *     // subtext 为 "CCCC"
	 * </pre>
	 * 
	 * </blockquote>
	 *
	 * @param str
	 *            被分隔的字符串
	 * @param istart
	 *            开始位置
	 * @param delimiter
	 *            分隔符
	 * @param index
	 *            分隔后的子串数组下标
	 * @return 第 index 个子串
	 */
	public final static String subSplitString(String str, int istart, char delimiter, int index) {
		if (str == null) {
			return null;
		}
		int sl = str.length();
		int i = istart;
		int j = 0;
		for (; i < sl;) {
			int iend = str.indexOf(delimiter, i);
			if (iend < 0) {
				break;
			}
			if (j++ == index) {
				return str.substring(i, iend);
			}
			i = iend + 1;
		}
		return j == index ? str.substring(i) : null;
	}

	/**
	 * 将 x[a] 和 x[b]交换；
	 *
	 * @param x
	 *            Description of the Parameter
	 * @param a
	 *            Description of the Parameter
	 * @param b
	 *            Description of the Parameter
	 */
	private static void swap(int x[], int a, int b) {
		int t = x[a];
		x[a] = x[b];
		x[b] = t;
	}

	/**
	 * Swaps x[a] with x[b].
	 *
	 * @param x
	 *            Description of the Parameter
	 * @param a
	 *            Description of the Parameter
	 * @param b
	 *            Description of the Parameter
	 */
	private static void swap(String x[], int a, int b) {
		String t = x[a];
		x[a] = x[b];
		x[b] = t;
	}

	/**
	 * Description of the Method
	 *
	 * @param obj
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static int toIntValue(Object obj) {
		return obj instanceof Number ? ((Number) obj).intValue() : 0;
	}

	/**
	 * 去掉一个字符串右边的空格.
	 *
	 * @param text
	 *            Description of the Parameter
	 * @return Description of the Return Value
	 */
	public final static String trimRight(String text) {
		if (text == null) {
			return null;
		}
		int l = text.length();
		for (; l > 0 && text.charAt(l - 1) <= ' '; l--) {
			;
		}
		return l == text.length() ? text : text.substring(0, l);
	}

	/**
	 * 将 x[a .. (a+n-1)] 和 x[b .. (b+n-1)]进行交换
	 *
	 * @param x
	 *            Description of the Parameter
	 * @param a
	 *            Description of the Parameter
	 * @param b
	 *            Description of the Parameter
	 * @param n
	 *            Description of the Parameter
	 */
	private static void vecswap(int x[], int a, int b, int n) {
		for (int i = 0; i < n; i++, a++, b++) {
			swap(x, a, b);
		}
	}

	/**
	 * add by yuelaohu
	 *
	 * @param strCon
	 *            字符串内容
	 * @param rowNo
	 *            行号 注意,行号从0开始算起
	 * @return 返回 取得的某一行的内容 如果字符串内容不存在,则返回"null"
	 */
	public static String getLineFromStr(String strCon, int rowNo) {
		String strLine = null;
		try {
			if (strCon == null)
				return null;
			String strLineArr[] = StringUtil.splitString(strCon, '\r');
			if (strLineArr == null || strLineArr.length < rowNo)
				return null;
			return strLineArr[rowNo].trim();

		} catch (Exception ex) {
			//NutzUtil.getLogger().error("字符传不正确！");
		}
		return strLine;
	}

	/**
	 * 左补零
	 * 
	 * @param s
	 *            待补零字符串
	 * @param len
	 *            补零后的总长度
	 * @return 如addZeroLeft('1',4)=0004
	 */
	public static String addZeroLeft(String s, int len) {
		if (DataTypeUtil.isEmptyStr(s))
			return s;
		if (s.length() >= len)
			return s;
		for (int i = s.length(); i < len; i++) {
			s = "0" + s;
		}
		return s;
	}

	/**
	 * 右补零
	 * 
	 * @param s
	 *            待补零字符串
	 * @param len
	 *            补零后的总长度
	 * @return 如addZeroRight('1',4)=1000
	 */
	public static String addZeroRight(String s, int len) {
		if (DataTypeUtil.isEmptyStr(s))
			return s;
		if (s.length() >= len)
			return s;
		for (int i = s.length(); i < len; i++) {
			s = s + "0";
		}
		return s;
	}

	public static int getLength(Object s) {
		if (DataTypeUtil.isEmptyStr(s))
			return 0;
		String ss = s.toString();
		char chrs[] = ss.toCharArray();
		int strlen = 0;
		for (int i = 0; i < chrs.length; i++) {
			String temp = new String(chrs[i] + "");
			if (temp.getBytes().length > 1) {
				strlen += 2;
			} else
				strlen++;
		}
		return strlen;
	}

	/**
	 * 当一个文本在网页中太长时，需要加入回车符号
	 * 
	 * @param src
	 *            长字符串
	 * @param enterLen
	 *            多少长度时增加enterStr
	 * @param enterStr
	 *            在网页中一般是<BR>
	 * @return
	 */
	public static String addEnter(String src, int enterLen, String enterStr) {
		if (DataTypeUtil.isEmptyStr(src))
			return src;
		if (src.toUpperCase().indexOf(enterStr) == -1) {
			String svalue = "";
			int len = src.length();
			if (len <= enterLen) {
				svalue = src;
			} else {
				int mod = len / enterLen;
				int yushu = len % enterLen;
				String s = "";
				for (int i = 0; i < mod; i++) {
					svalue += src.substring(i * enterLen, (i + 1) * enterLen);
					svalue += "<BR>";
				}
				if (yushu > 0) {
					svalue += src.substring(mod * enterLen, src.length());
				}
			}
			return svalue;
		}
		return src;
	}



}
